import request from '@/utils/axios'

export interface DepartType {
  id: number | undefined
  parentId: number | undefined
  name: string | undefined
  sort: number
  leaderUserId: number | undefined
  mobile: string
  email: string
  status: number
  remark: string
}

/**
 * 部门接口
 */
export const DepartApi = {
  // 新增
  create: (data: DepartType) => {
    return request.post({ url: '/system/depart/create', data, is_mock: true })
  },
  // 修改
  update: (data: DepartType) => {
    return request.put({ url: '/system/depart/update', data, is_mock: true })
  },
  // 删除
  delete: (id: number) => {
    return request.delete({ url: '/system/depart/delete?id=' + id, is_mock: true })
  },
  // 查询详情
  detail: (id: number) => {
    return request.get({ url: '/system/depart/detail?id=' + id, is_mock: true })
  },
  // 查询列表
  list: (): Promise<DepartType[]> => {
    return request.get({ url: '/system/depart/list', is_mock: true })
  },
  // 查询精简列表
  simple: (): Promise<DepartType[]> => {
    return request.get({ url: '/system/depart/simple-list', is_mock: true })
  },
  // 获取当前登录用户可看到的部门
  getDepartByUser: async () => {
    return await request.post({ url: '/User/userdepart' })
  }
}
